import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBApplication.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBWorkTaiModule/YBFenXiangHuKePage/YBCustomImagePage.dart';
import 'package:zefyr/zefyr.dart';



class YBWenZhangYuanChuangPage extends StatefulWidget {
  @override
  _YBWenZhangYuanChuangPageState createState() => _YBWenZhangYuanChuangPageState();
}

class _YBWenZhangYuanChuangPageState extends State<YBWenZhangYuanChuangPage> {

  final ZefyrController _controllor = ZefyrController(NotusDocument());
  final FocusNode _focusNode = FocusNode();
  final TextEditingController _editingController = TextEditingController();


  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        resizeToAvoidBottomPadding: true,
        appBar: AppBar(
          elevation: 0,
          title: Text(YBChineseText.workTaiEditTitle),
          actions: [
            Container(
              child: InkWell(
                child: Padding(
                  padding: EdgeInsets.only(right: YBTextStyle.adapterSize20),
                  child: Center(
                    child: Text(YBChineseText.workTaiEditTitle,style: YBTextStyle.TextStyle1C1D1F15,),
                  ),
                ),
                onTap: () async {
                  YBApplication.router.navigateTo(context, '/workTaiPage/workTaizhuanzaiWechatWenZhangPage/workTaiYuanchuangFengMainYePage?title=${Uri.encodeComponent(_editingController.text)}&&content=${Uri.encodeComponent(jsonEncode(_controllor.document))}');
                },
              ),
            ),
          ],
        ),
        body: ZefyrScaffold(
          child: Padding(
            padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20),
            child: ListView(
              children: [
                TextField(decoration: InputDecoration(hintText: YBChineseText.workTaiInputTitle),controller: _editingController,),
                ZefyrField(
                  height: YBTextStyle.adapterSize200,
                  decoration: InputDecoration(labelText: YBChineseText.workTaiInputTextTitle),
                  controller: _controllor,
                  focusNode: _focusNode,
                  autofocus: true,
                  imageDelegate: YBCustomImagePage(),
                  physics: ClampingScrollPhysics(),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
